#include <gl/glew.h>
#define GLFW_DLL
#include <gl/glfw.h>

#include "renderer/font.h"

#include <iostream>

Font::Font(){
    LoadAllFonts();
}

Font::~Font(){
    delete font;
}

void Font::LoadAllFonts(){
    font = new FTGLPixmapFont("data//fonts//times.ttf");
    if(font->Error()){
        std::cout<<"Error loading font: times.ttf\n";
        return;
    }
    font->FaceSize(72);
}

void Font::Write(std::string text, int x, int y, int size){
    int program;
    glGetIntegerv(GL_CURRENT_PROGRAM, &program);
    glUseProgram(0);
    font->FaceSize(size);
    font->Render(text.c_str(), -1, FTPoint(x, y));
    glUseProgram(program);
}

